export const state = {
    // userInfo: {}
    userInfo: sessionStorage.getItem("userInfo") ? JSON.parse(sessionStorage.getItem("userInfo")) : {}
}
export const mutations = {
    chnagUserInfo(state, obj) {
        if (obj.token) {
            //登录
            state.userInfo = obj
            //保存到本地
            sessionStorage.setItem("userInfo", JSON.stringify(obj))
        } else {
            //退出
            state.userInfo = obj
            sessionStorage.removeItem("userInfo")
        }

    }
}
export const getters = {
    userInfo(state) {
        return state.userInfo
    }
}
